<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport"
	      content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Promise</title>
	<script src="Promise.js"></script>
</head>
<body>

</body>
</html>
<script>
	// let p=new Promise(((resolve, reject) => {
	// 	setTimeout(()=>{
	// 		reject ('error');
	// 	},500);
  //    // reject('ok');
	// 	// throw 'error'
	// }));
	// p.then(value => {
	// 	alert(value)
	// },reason => {
	// 	console.log(reason)
	// })
	// let p2=Promise.resolve('ok');
	// console.log(p2)
	// let p3=Promise.reject('no');
	// console.log(p3)
	// let p4=Promise.resolve('hh')
	// let p5=Promise.all([p2,p3,p4]);
	// console.log(p5)
	// let p6=Promise.allSettled([p2,p3,p4])
	// p6.then(res=>{
	// 	console.log(res)
	// })
	const pErr = new Promise((resolve, reject) => {
		reject("总是失败");
	});

	const pSlow = new Promise((resolve, reject) => {
		setTimeout(reject, 500, "最终完成");
	});

	const pFast = new Promise((resolve, reject) => {
		setTimeout(reject, 100, "很快完成");
	});
 let p=Promise.any([pErr, pSlow, pFast]);
	console.log(p)
	p.then((value) => {
		console.log(value,'1');
		// pFast fulfils first
	},reason=>{
		console.log(reason)
	}).catch(e=>{
		console.log(e)
	}).finally(()=>{
		console.log(111)
	});
	// console.log(p6)
</script>
